HOME BLOG GITHUB
Why Twos Complement Negative Numbers Negative Numbers Why Twos Complement Why Twos Complement Negative Numbers->Why Twos Complement

November 22, 2020

Why Twos Complement

Because the computer calculates faster in this representation.

The Reason behind Two's Complement Representation

Why are we using such a complicated formula? Because the goal of computers is to compute (perform operations on numbers) and this representation helps our electronic components handle the data. For example, using the two's complement reprsentation it is straightforward to add two numbers. The addition rule is the same as with positive numbers (adding bits one by one with the carry):

Decimal addition Binary addition Binary result Decimal result
6 + (-4) 0110 + 1100 (1)0010 2

The second advantage of this representation is we can easily implement subtraction: to perform a - b, we only need to transform b into its two's complement representation and then add the two numbers a + (-b).